package com.cloudeasy.server.util;

import com.cloudeasy.api.vo.user.PermissionVO;
import com.cloudeasy.server.po.Permission;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class PermissionUtil {

    /**
     * 转换
     *
     * @param permissions {@link List<Permission>}
     * @return {@link List<PermissionVO>}
     */
    public static List<PermissionVO> convert(List<Permission> permissions) {
        return permissions.stream().map(permission -> {
            PermissionVO permissionVO = new PermissionVO();
            BeanUtils.copyProperties(permission, permissionVO);
            return permissionVO;
        }).collect(Collectors.toList());
    }
}
